##
# Creates the .pdf `object' file list for use during compilation.
#
PDF := $(shell ls *.tex | sed 's/tex/pdf/g' )
SVG := $(shell ls *.tex | sed 's/tex/svg/g' )

phony: all build tempclean

all: build tempclean

build-pdf: $(PDF)

build-svg: $(SVG)

build: build-pdf build-svg

# Compile all .tex images using xelatex
%.pdf: %.tex
	xelatex $<

# Convert all .pdf to .svg
%.svg: %.pdf
	inkscape $< --pdf-poppler --export-type="svg" --export-overwrite --export-plain-svg

# Remove all the cruft generated by pdflatex
tempclean:
	rm -rf auto *.log *.aux *.out *~

# Remove the generated pdf images
clean: tempclean
	rm -f *.pdf *~ *.eps *.dvi
